<%@ page import="javax.sql.*"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>


<html>
<head></head>
<body>
	<p>
		Hello <b><%=request.getUserPrincipal().getName()%></b>!
	</p>
	<p>Roles: &nbsp;&nbsp;Admin</p>


	<!-- in case validation of the entry data fails in the data bean -->
	<html:errors />

	<table>
		<tr>
			<td>
				<!-- Add an HTML table header row to format the results -->
				<table>
					<tr>
						<th>ID</th>
						<th>Username</th>
						<th>Password</th>
					</tr>
					<tr>
						<html:form action="/addReviewer">
							<td>&nbsp;</td>
							<td><html:text property="username" size="15" />
							</td>
							<td><html:text property="password" size="15" />
							</td>
							<td><html:submit value="Add Reviewer" />
							</td>
							<td><html:reset />
							</td>
						</html:form>
					</tr>


					<%-- -------- Iteration Code -------- --%>
					<%
						// Get the studentsRowSet
						RowSet crsReviewer = (RowSet) request.getAttribute("crsReviewer");

						// Iterate over the RowSet
						if (crsReviewer != null)
							while (crsReviewer.next()) {
					%>

					<!-- The value is from database -->
					<tr>
						<html:form action="/updateReviewer">
							<td><html:text property="username" size="15" />
							</td>

							<td><html:text property="password" size="15" /></td>

							<%-- Button --%>
							<td><html:submit value="Update Reviewer" />
							</td>
						</html:form>

						<html:form action="/deleteReviewer">
							<html:hidden property=""
								value="<%=Integer.toString(crsReviewer.getInt(1)) %>" />
							<td><html:submit value="Delete Reviewer" />
							</td>
						</html:form>
					</tr>
					<%
						}
					%>
				</table></td>
		</tr>
	</table>
</body>
</html>
